home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / utility / ffe101.zip / ANIM.SWG / 0005_FLI and FLC EXPLANATION.pas < prev    next >
Pascal/Delphi Source File  |  1996-09-03  |  10KB  |  242 lines

  1. --------a-FLI-------------------------------
  2.  
  3. Flic Files (.FLI) Format description:
  4.  
  5.      The  details  of  a FLI file  are  moderately complex, but the idea
  6. behind  it is simple: don't bother storing the parts of a frame that are
  7. the same as the last frame. Not only does this save space, but it's very
  8. quick. It's faster to leave a pixel alone than to set it.
  9.  
  10.      A  FLI file has a 128-byte header followed by a sequence of frames.
  11. The  first  frame is compressed  using a bytewise run-length compression
  12. scheme. Subsequent frames are stored as the difference from the previous
  13. frame.  (Occasionally  the  first  frame  and/or  subsequent  frames are
  14. uncompressed.)  There  is  one  extra frame at  the  end  of a FLI which
  15. contains the difference between the last frame and the first frame.
  16.  
  17.      The FLI header:
  18.  
  19.      byte size name      meaning
  20.      offset
  21.  
  22.      0    4    size      Length of file, for programs that want
  23.                          to read the FLI all at once if possible.
  24.      4    2    magic     Set to hex AF11.  Please use another
  25.                          value here if you change format (even to
  26.                          a different resolution) so Autodesk
  27.                          Animator won't crash trying to read it.
  28.      6    2    frames    Number of frames in FLI.  FLI files have
  29.                          a maxium length of 4000 frames.
  30.      8    2    width     Screen width (320).
  31.      10   2    height    Screen height (200).
  32.      12   2    depth     Depth of a pixel (8).
  33.      14   2    flags     Must be 0.
  34.      16   2    speed     Number of video ticks between frames.
  35.      18   4    next      Set to 0.
  36.      22   4    frit      Set to 0.
  37.      26   102  expand    All zeroes -- for future enhancement.
  38.  
  39.      Next are the frames, each of which has a header:
  40.  
  41.      byte size name      meaning
  42.      offset
  43.      0    4    size      Bytes in this frame.  Autodesk Animator
  44.                          demands that this be less than 64K.
  45.      4    2    magic     Always hexadecimal F1FA
  46.      6    2    chunks    Number of 'chunks' in frame.
  47.      8    8    expand    Space for future enhancements.  All
  48.                          zeros.
  49.  
  50.      After  the  frame  header come the  chunks  that make up the frame.
  51. First  comes  a color chunk if the  color  map has changed from the last
  52. frame. Then comes a pixel chunk if the pixels have changed. If the frame
  53. is  absolutely  identical to the last frame  there  will be no chunks at
  54. all.
  55.  
  56.      A chunk itself has a header, followed by the data.  The
  57. chunk header is:
  58.  
  59.      byte size name meaning
  60.      offset
  61.      0    4    size Bytes in this chunk.
  62.      4    2    type Type of chunk (see below).
  63.  
  64.      There are currently five types of chunks you'll see in a FLI file.
  65.  
  66.      number    name      meaning
  67.      11        FLI_COLOR Compressed color map
  68.      12        FLI_LC    Line compressed -- the most common type
  69.                          of compression for any but the first
  70.                          frame.  Describes the pixel difference
  71.                          from the previous frame.
  72.      13        FLI_BLACK Set whole screen to color 0 (only occurs
  73.                          on the first frame).
  74.      15        FLI_BRUN  Bytewise run-length compression -- first
  75.                          frame only
  76.      16        FLI_COPY  Indicates uncompressed 64000 bytes soon
  77.                          to follow.  For those times when
  78.                          compression just doesn't work!
  79.  
  80.      The  compression  schemes are all  byte-oriented. If the compressed
  81. data  ends up being an odd length a  single pad byte is inserted so that
  82. the FLI_COPY's always start at an even address for faster DMA.
  83.  
  84. FLI_COLOR
  85.  
  86. Chunks  The  first word is the number  of packets in this chunk. This is
  87. followed  directly  by the packets. The first  byte of a packet says how
  88. many  colors  to skip. The next byte  says how many colors to change. If
  89. this  byte  is zero it is interpreted  to mean 256. Next follows 3 bytes
  90. for each color to change (one each for red, green and blue).
  91.  
  92. FLI_LC Chunks
  93.  
  94.      This  is  the most common, and  alas, most complex chunk. The first
  95. word  (16  bits)  is the number of  lines  starting  from the top of the
  96. screen  that are the same as the  previous frame. (For example, if there
  97. is  motion only on the bottom line of screen you'd have a 199 here.) The
  98. next  word is the number of lines that do change. Next there is the data
  99. for the changing lines themselves. Each line is compressed individually;
  100. among  other things this makes it much easier  to play back the FLI at a
  101. reduced size.
  102.  
  103.      The  first  byte of a compressed line  is  the number of packets in
  104. this  line.  If the line is unchanged  from the last frame this is zero.
  105. The format of an individual packet is:
  106.  
  107. skip_count
  108. size_count
  109. data
  110.  
  111.      The  skip count is a single byte. If more than 255 pixels are to be
  112. skipped it must be broken into 2 packets. The size count is also a byte.
  113. If  it is positive, that many bytes of  data follow and are to be copied
  114. to  the screen. If it's negative a  single byte follows, and is repeated
  115. -skip_count times.
  116.  
  117.      In  the worst case a FLI_LC frame can be about 70K. If it comes out
  118. to  be  60000 bytes or more  Autodesk Animator decides compression isn't
  119. worthwhile and saves the frame as FLI_COPY.
  120.  
  121. FLI_BLACK Chunks
  122.  
  123.      These  are  very simple. There is  no  data associated with them at
  124. all.  In  fact they are only generated  for  the first frame in Autodesk
  125. Animator after the user selects NEW under the FLIC menu.
  126.  
  127. FLI_BRUN Chunks
  128.  
  129.      These  are  much like FLI_LC chunks  without  the skips. They start
  130. immediately  with the data for the first line, and go line- by-line from
  131. there.  The first byte contains the number  of packets in that line. The
  132. format for a packet is:
  133.  
  134. size_count
  135. data
  136.  
  137.      If  size_count is positive the data consists of a single byte which
  138. is  repeated  size_count  times.  If  size_count  is  negative there are
  139. -size_count  bytes  of data which are  copied to the screen. In Autodesk
  140. Animator  if the "compressed" data shows  signs of exceeding 60000 bytes
  141. the frame is stored as FLI_COPY instead.
  142.  
  143. FLI_COPY Chunks
  144.  
  145.      These are 64000 bytes of data for direct reading onto the screen.
  146.  
  147. -----------------------------------------------------------------------
  148. And here's the PRO extensions:
  149. -----------------------------------------------------------------------
  150.  
  151. This is supplemental info on the AutoDesk Animator FLI and FLC formats.
  152.  
  153. The  following  is an attempt at  describing the newer chunks and frames
  154. that are not described in the Turbo C FLI library documentation.
  155.  
  156.   Chunk type       Chunk ID
  157.   ----------       -----------
  158.   FLI_DELTA        7 (decimal)
  159.  
  160. First  WORD (16 bits) is the number  of compressed lines to follow. Next
  161. is  the data for the changing lines themselves, always starting with the
  162. first line. Each line is compressed individually.
  163.  
  164. The  first WORD (16 bits) of a  compressed line is the number of packets
  165. in the line. If the number of packets is a negative skip -packets lines.
  166. If  the number of packets is positive, decode the packets. The format of
  167. an individual packet is:
  168.  
  169.   skip_count
  170.   size_count
  171.   data
  172.  
  173. The  skip  count  is a single byte. If  more  than  255 pixels are to be
  174. skipped,  it  must  be broken into 2  packets.  The size_count is also a
  175. byte.  If  it is positive, that many WORDS  of data follow and are to be
  176. copied  to the screen. If it is  negative, a single WORDS value follows,
  177. and is to be repeated -size_count times.
  178.  
  179.   Chunk type       Chunk ID
  180.   ----------       -----------
  181.   FLI_256_COLOR    4 (decimal)
  182.  
  183. The  first WORD is the number of packets in this chunk. This is followed
  184. directly  by the packets. The first byte  of a packet is how many colors
  185. to  skip. The next byte is how many  colors to change. If this number is
  186. 0,  (zero), it means 256. Next follow  3 bytes for each color to change.
  187. (One each for red, green and blue).
  188.  
  189. The only difference between a FLI_256_COLOR chunk (type 4 decimal) and a
  190. FLI_COLOR chunk (type 11 decimal) is that the values in the type 4 chunk
  191. range  from 0 to 255, and the values in  a type 11 chunk range from 0 to
  192. 63.
  193.  
  194.   NOTE:  WORD  refer to a 16 bit int in INTEL (Little Endian) format.
  195.          WORDS refer to two-bytes (16 bits) of consecutive data. (Big Endian)
  196.  
  197.   .FLC special frames and chunks
  198.  
  199.   FLC's may contain all the above chunks plus one other:
  200.  
  201.   Chunk type       Chunk ID
  202.   ----------       -----------
  203.   FLI_MINI         18 (decimal) 12 (Hex)
  204.  
  205. From  what I understand, this is a miniture 64 x 32 version of the first
  206. frame  in  FLI_BRUN format, used as  an  button for selecting flc's from
  207. within Animator Pro. Simply do nothing with this chunk.
  208.  
  209.   FLC New Frame
  210.  
  211. FLC's  also contains a frame with the  magic bytes set to hex 00A1. This
  212. is  the  first frame in the .flc file.  Actually it isn't a frame at all
  213. but  to  have several chunks within  it  that specify file location info
  214. specific to Animator Pro. IE: filepath, font to use, and .COL file info.
  215. This  FRAME  may be skipped while  loading. That's right! Ignore it! The
  216. frame header is the same length as all other frames. So you may read the
  217. frame header, then skip past the rest of the frame.
  218.  
  219.  
  220. NOTE:  When  reading the FLI header on  the newer FLI and FLC files, the
  221. FLI  signature  bytes  are AF12 instead of  AF11  used  in the older FLI
  222. files.  Also, you cannot ignore the screen width and height they may not
  223. be 320 x 200.
  224.  
  225.   Allowable screen sizes include:
  226.  
  227.   320 x 200, 640 x 480, 800 x 600, 1280 x 1024
  228.  
  229.  
  230.   NOTE:  the delay value between frames appears to be in 1000th's of a
  231.   second instead of 70th's.
  232.  
  233. If you have any questions or more info on the FLI or FLC formats, please
  234. let me know.
  235.  
  236. EXTENSION:FLC,FLI
  237. OCCURENCES:PC
  238. PROGRAMS:Autodesk Animator (Pro)
  239. SEE ALSO:FLIc,FLC,PIC,CEL,COL,FLT
  240.  
  241.  
  242.